package topday1_9.chj;

/**
 * @Auther:小陈的Java
 */

public class NumberUtils {
    void printMaxAndMin(double... args) {
        double min;
        double max;
        double sum =0;
        double avg;
        if(args.length>0) {
            min = args[0];
            max = args[0];
            for(int i=0;i<args.length;i++) {
                if(min>args[i]) {
                    min = args[i];
                }
                if(max<args[i]) {
                    max = args[i];
                }
                sum += args[i];
            }
            avg = sum/args.length;
            System.out.println("最大值:"+max);
            System.out.println("最小值:"+min);
            System.out.println("和:"+sum);
            System.out.println("平均值:"+avg);
        } else {
            System.out.println("没有传递参数无法计算");
        }

    }
    public static void main(String[] args) {
        NumberUtils numberUtils = new NumberUtils();
        numberUtils.printMaxAndMin(-3.1,5.7,3.14,5.99,9.21);
        numberUtils.printMaxAndMin();
    }
}
